home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / bmgrep.arc / MKDESC.C < prev    next >
Text File  |  1986-12-10  |  780b  |  27 lines

  1. #include "bm.h"
  2. #include <string.h>
  3. /* scan a newline-separated string of patterns and set up the
  4. * vector of descriptors, one pattern descriptor per pattern. 
  5. * Return the number of patterns */
  6. int MkDescVec(DescVec, Pats)
  7. struct PattDesc *DescVec[];
  8. char *Pats;
  9. {
  10.     int NPats = 0;
  11.     char *EndPat;
  12.     extern struct PattDesc *MakeDesc();
  13. /* some systems use "strchr" instead of "index" */
  14.    while (*Pats && (EndPat = index(Pats,'\n')) && NPats < MAXPATS) { 
  15. /*    while (*Pats && (EndPat = strchr(Pats,'\n')) && NPats < MAXPATS) { */
  16.         *EndPat = '\0';
  17.         DescVec[NPats] = MakeDesc(Pats);
  18.         Pats = EndPat + 1;
  19.         ++NPats;
  20.     } /* while */
  21.     if (*Pats && NPats < MAXPATS) {
  22.         DescVec[NPats] = MakeDesc(Pats);
  23.         ++NPats;
  24.     } /* if */
  25.     return(NPats);
  26. } /* MkDescVec */
  27.